<?php
namespace StarCloud\Models;

trait BalanceFlowRecordBase
{
    public static function newRecord($uid, $type, $amount, $balance, $objectId, array $objectJson)
    {
        $record = new static();
        $record->uid = $uid;
        $record->type = $type;
        $record->amount = $amount;
        $record->balance = $balance;
        $record->object_id = $objectId;
        $record->object_json = json_encode($objectJson);
        $record->save();

        return $record;
    }

    // 表的字段
    protected $id;
    protected $uid;
    protected $type;
    protected $amount;
    protected $balance;
    protected $object_id;
    protected $object_json;
    protected $created_at;
    protected $updated_at;
}
